package com.alibaba.datax.core.util.geo.response;

public class ApiResult<T> {
    private static final int SUCCESS_RET_CODE = 0;
    private static final String SUCCESS_MSG = "请求成功";
    private static final int FAILURE_RET_CODE = 999;
    private static final String FAILURE_MSG = "请求失败";
    private int retCode;
    private String msg;
    private T data;

    public ApiResult() {
    }

    public ApiResult(T data) {
        this(0, "请求成功", data);
    }

    public ApiResult(int retCode, String msg) {
        this(retCode, msg, null);
    }

    public ApiResult(int retCode, String msg, T data) {
        this.retCode = retCode;
        this.msg = msg;
        this.data = data;
    }

    public static ApiResult ok() {
        return new ApiResult(0, "请求成功");
    }

    public static ApiResult ok(String msg) {
        return new ApiResult(0, msg);
    }

    public static ApiResult failure() {
        return new ApiResult(999, "请求失败");
    }

    public static ApiResult failure(int retCode, String msg) {
        return new ApiResult(retCode, msg);
    }

    public int getRetCode() {
        return this.retCode;
    }

    public void setRetCode(int retCode) {
        this.retCode = retCode;
    }

    public String getMsg() {
        return this.msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return this.data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
